﻿<Serializable()>
Public Class CPUMeasurementTest

    Public Property ServerName As String
    Public Property MeasureMentDate As DateTime
    Public Property CPUMeasurement As Double


    Public Sub New()




    End Sub

    Public Sub New(ByVal testMeasurementDate As DateTime, ByVal _ServerName As String, ByVal _CPUMeasurement As Double)
        CPUMeasurement = _CPUMeasurement

        MeasureMentDate = testMeasurementDate

        ServerName = _ServerName


    End Sub



    Public Sub PerformCPUTest(ByVal _ServerName As String)

        '  Dim TimeOfTest As DateTime = System.DateTime.Now
        Me.MeasureMentDate = System.DateTime.Now()

        Dim aCounter As New PerformanceCounter("Processor", "% Processor Time", "_Total", _ServerName)
        ' Dim thisTest As CPUMeasurementTest
        Using aCounter

            Dim Measurement As Double

            aCounter.NextValue()
            System.Threading.Thread.Sleep(1000)

            Measurement = aCounter.NextValue() / Environment.ProcessorCount


            Me.CPUMeasurement = Measurement
            Me.ServerName = _ServerName

            '     thisTest = New CPUMeasurementTest(TimeOfTest, ServerName, Measurement)

        End Using




    End Sub




End Class
